<template>
    <div>
        <h3>SubItem组件</h3>
        <p>已知库存数：{{ count }}</p>
        <button @click="subFn">库存-1</button>
        <button @click="asyncSubFn">延迟1S，库存-5</button>
        <button @click="doubleFn">翻倍（减少）</button>
        <p>{{ doubleCount }}</p>
    </div>
</template>

<script>
import { mapState } from 'vuex'
import { mapMutations } from 'vuex';
import { mapActions } from 'vuex';
import { mapGetters } from 'vuex';
export default{
    computed:{
        ...mapState(['count']),
        ...mapGetters(['doubleCount']),
    },
    methods:{
        ...mapMutations(['subCounts']),
        ...mapActions(['asyncSubCount']),
        subFn(){
            this.subCounts(1)
        },
        asyncSubFn(){
            this.asyncSubCount(5)
        },
        doubleFn(){

        }
    }
}
</script>

<style>

</style>